This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
rm(list = ls())
graphics.off()
library(ggplot2); library(ggthemes); library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v tibble 3.1.6 v dplyr 1.0.8
## v tidyr 1.2.0 v stringr 1.4.0
## v readr 2.1.2 v forcats 0.5.1
## v purrr 0.3.4
## Warning: package 'tidyr' was built under R version 4.1.3
## Warning: package 'readr' was built under R version 4.1.3
## Warning: package 'dplyr' was built under R version 4.1.3
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
setwd('C:/Users/iande/Downloads/seminario R/')
data <- read.csv('salarios usp 2020.csv', sep = ';')
per <- data[-which(data$Depto.Setor=='Inativo'),]
per <- per[per$Unid.Orgao=='IGc',]
per %>% filter(Classe %in% c('Superior 1','Superior 2','Superior 3','Superior 4')) -> sup
per %>% filter(Classe %in% c('Técnico 1','Técnico 2', 'Técnico 3')) -> tec
per %>% filter(Classe %in% c('Prof Doutor','Prof Titular')) -> doc
lm(tec$Liquido~tec$Tempo_USP)
##
## Call:
## lm(formula = tec$Liquido ~ tec$Tempo_USP)
##
## Coefficients:
## (Intercept) tec$Tempo_USP
## 4889.3 189.2
lm(sup$Liquido~sup$Tempo_USP)
##
## Call:
## lm(formula = sup$Liquido ~ sup$Tempo_USP)
##
## Coefficients:
## (Intercept) sup$Tempo_USP
## 7031.3 351.9
lm(doc$Liquido~doc$Tempo_USP)
##
## Call:
## lm(formula = doc$Liquido ~ doc$Tempo_USP)
##
## Coefficients:
## (Intercept) doc$Tempo_USP
## 8607.3 486.6
#pdf('salarios.pdf',height = 10, width = 12)
par(mar=c(5,5,1.5,1.5))
ggplot(per, aes(Tempo_USP, Liquido, group = Nome))+
geom_point(aes(colour=Classe),size=3)+
labs(x='Tempo USP (anos)', y = 'Salario Liquido (R$)')+
theme_bw()+
theme(axis.text.x = element_text(size = 15, angle = 0, hjust = 0.5),
axis.text.y = element_text(size = 15),
axis.title.x = element_text(size = 15),
axis.title.y = element_text(size = 15),
axis.ticks = element_line(size = 1),
axis.ticks.length = unit(.2, 'cm'),
legend.position = 'top',
legend.title = element_blank(),
legend.text = element_text(size = 15),
panel.border = element_rect(fill = NA))->g1
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.